import { BaseObject } from '@/types/global';

export const loadFuncMap = import.meta.glob('/src/docs/*.md');
export async function load(name) {
  return loadFuncMap[`/src/docs/${name}.md`]().then((obj: BaseObject) => {
    return {
      name,
      ...obj,
    };
  });
}
export async function loadAll() {
  return Object.keys(loadFuncMap).map((key) => {
    const name = key.replace(/\/src\/docs\/|.md/g, '');
    return load(name);
  });
}
